package model;

import java.util.ArrayList;

import controller.ByNameController;

/**
 * Select only the contact with the name enter by the user and put them in an array
 * @author Marie Morin
 *
 */

public class ByNameModel {

	private ByNameController c;
	private ArrayList<Contact> newContactsList= new ArrayList<Contact>();
	private String text;
	
	public ByNameModel(ByNameController c){

		this.c = c;
		
	       
		
		
		
		if (c.getContactsList().size()>0){
			
			for (int i=0; i< c.getContactsList().size(); i++){
				
				
				if (this.c.getContactsList().get(i).getAname().toLowerCase().contains(c.getText().toLowerCase()))
				{				
					newContactsList.add(c.getContactsList().get(i));
				}
			
			}
			
			c.setContactsList(newContactsList);	
			
		}
		
		
		
	}

}

